from flask import request

from approval_service.approval.service.reimbursement_approval_fi_service import ReimbursementApprovalFiService
from commons.controller.base_controller import BaseController


class ReimbursementApprovalFiController(BaseController):
    def __init__(self):
        self.reimbursement_approval_fi_service = ReimbursementApprovalFiService()

    def get_by_reimbursement_approval_fi_id_by_id(self):
        """
        根据财务人员审批报销申请记录ID获取财务人员审批报销申请记录信息。
        """
        # 从请求体解析参数
        data = request.get_json()
        reimbursement_approval_fi_id_id = data.get("reimbursementApprovalFiId")

        return BaseController.get_success_response(self,
                                                   self.reimbursement_approval_fi_service.
                                                   get_reimbursement_approval_fi_by_reimbursement_approval_fi_id(
                                                       reimbursement_approval_fi_id_id))

    def get_by_reimbursement_approval_fi_id_by_reimbursement_id(self):
        """
        根据报销ID获取财务人员审批报销申请记录信息。
        """
        # 从请求体解析参数
        data = request.get_json()
        reimbursement_id = data.get("reimbursementId")

        return BaseController.get_success_response(self,
                                                   self.reimbursement_approval_fi_service.
                                                   get_reimbursement_approval_fi_by_reimbursement_id(
                                                       reimbursement_id))
    def get_approve_reimbursement_record_fi(self):
        """
        获取审批的报销申请记录。
        """
        # 从请求体解析参数
        data = request.get_json()
        user_id = data.get("userId")
        page_no = data.get("pageNo")
        page_size = data.get("pageSize")

        return BaseController.get_success_response(self, self.reimbursement_approval_fi_service.
                                                   get_approve_reimbursement_record_fi(user_id, page_no, page_size))
